package com.software.practicecenter.service;

import com.software.practicecenter.entity.Passage;
import com.software.practicecenter.repository.PassageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PassageService {
    @Autowired
    private PassageRepository passageRepository;

    @Autowired
    private SubPassageService subPassageService;


//    public List<PassageData> findAll() {
////        List<Passage> all = passageRepository.findAll().stream().sorted(Comparator.comparing(Passage::getNo)).collect(Collectors.toList());
//        List<Passage> all = passageRepository.findAll();
//        List<PassageData> passageDataList = new ArrayList<>();
//        for (int i =0;i< all.size();i++){
//            String id = all.get(i).getId();
//            List<SubPassageDTO> byPassageId = subPassageService.findByPassageId(id);
//            PassageData passageData = new PassageData();
//            passageData.setPassage(all.get(i));
//            passageData.setSubPassageDTOS(byPassageId);
//            passageDataList.add(passageData);
//        }
//
//        return passageDataList;
//    }

    public List<Passage> findAll(){
        return passageRepository.findAll();
    }
}
